package com.cskaoyan.market.service;

import com.cskaoyan.market.db.domain.*;
import com.cskaoyan.market.db.mapper.MarketGoodsMapper;
import com.cskaoyan.market.db.mapper.MarketGoodsProductMapper;
import com.cskaoyan.market.db.mapper.MarketOrderMapper;
import com.cskaoyan.market.db.mapper.MarketUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: YaLiFeng
 * @description: TODO
 * @date: 2024/5/8 17:16
 */
@Service
public class AdminDashBoardServiceImpl implements AdminDashBoardService {
    @Autowired
    @Qualifier("marketUserMapper")
    MarketUserMapper marketUserMapper;
    @Autowired
    @Qualifier("marketOrderMapper")
    MarketOrderMapper marketOrderMapper;
    @Autowired
    @Qualifier("marketGoodsMapper")
    MarketGoodsMapper marketGoodsMapper;
    @Autowired
    @Qualifier("marketGoodsProductMapper")
    MarketGoodsProductMapper marketGoodsProductMapper;
    @Override
    public Map<String,Integer> count() {


        MarketUserExample marketUserExample=new MarketUserExample();
        MarketGoodsExample marketGoodsExample=new MarketGoodsExample();
        MarketGoodsProductExample marketGoodsProductExample=new MarketGoodsProductExample();
        MarketOrderExample marketOrderExample=new MarketOrderExample();
        Map<String,Integer> items=new HashMap<>();

        int userTotal= (int) marketUserMapper.countByExample(marketUserExample);
        int goodsTotal= (int) marketGoodsMapper.countByExample(marketGoodsExample);
        int productTotal= (int) marketGoodsProductMapper.countByExample(marketGoodsProductExample);
        int orderTotal= (int) marketOrderMapper.countByExample(marketOrderExample);
        items.put("userTotal",userTotal);
        items.put("goodsTotal",goodsTotal);
        items.put("productTotal",productTotal);
        items.put("orderTotal",orderTotal);
        return items;
    }
}
